merchantService.$inject = ['$http'];

function merchantService($http) {
    var appContext = require('../../../config/app.context');
    var urlBase = appContext.path + '/api';
    var _merchantService = {};

    _merchantService.getAllMerchants = function() {
        // return [
        //     { id: '1223', name: 'aa', address: 'axxx' },
        //     { id: '4842', name: 'ba', address: 'aaxxx' }            
        // ]
        return $http.get(urlBase + '/merchants');
    }

    _merchantService.getMerchantById = function(mId) {
        // return {
        //     id: mId,
        //     name: 'aaaz',
        //     address: 'xxsds',
        //     dish: [
        //         { id: '654', name: 'haod', type: '小吃', price: 12.5 },
        //         { id: '321', name: 'hasd', type: '小吃', price: 15.5 }
        //     ]
        // }
        return $http.get(urlBase + '/merchants/' + mId);
    }

    _merchantService.getCommentListByMerchantId = function(mId) {
        return $http.get(urlBase + '/comments/getByMerchantId/' + mId);
    }

    return _merchantService;
}

module.exports = merchantService;